home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / base.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  2.5 KB  |  83 lines

  1. // *********** GLOBAL VARS *****************************
  2.  
  3. var helpDoc = MM.HELP_inspBase;
  4.  
  5. // ******************** API ****************************
  6. function canInspectSelection(){
  7.   return true;
  8. }
  9.  
  10. //look at target
  11. //if in list of targets, set to list item
  12. //if not, add to bottom of list and set it
  13.  
  14.  
  15. function inspectSelection(){
  16.   var frameName,counter,frameList,listLen,counter,bTargetFound=false;
  17.   var baseObj = getSelectedObj(),targetVal;
  18.   var hrefVal = baseObj.getAttribute("href");
  19.   var Href = findObject("Href");
  20.   var frameTarget = findObject("frameTarget");
  21.   var counter=5; //add frame names to picklist after standard frame targets
  22.   //populate frame target picklist
  23.   frameList=getObjectRefs("NS 4.0","parent","frame"); //get list of frames
  24.   if (frameList && frameList.length>0) { //if frames
  25.   //if the frame has a name, add name to target picklist
  26.     for (i=0; i<frameList.length; i++) {
  27.       if (frameList[i].indexOf('unnamed')==-1){ //if the frame has a name
  28.         frameName=frameList[i].substring(frameList[i].indexOf("['")+2,frameList[i].indexOf("']"));
  29.         frameTarget.options[counter++] = new Option(frameName); 
  30.   }}}
  31.  
  32.   //if base target value exists and matches choice in target picklist, set it
  33.   //otherwise, add to bottom of picklist and select it
  34.   if (baseObj.getAttribute("target")){
  35.      targetVal = baseObj.getAttribute("target");
  36.      for (i=0;i<counter&&!bTargetFound;i++){  //look for existing match in frame picklist
  37.        if (targetVal==frameTarget.options[i].text){
  38.          frameTarget.selectedIndex=i;
  39.          bTargetFound=true;
  40.        }
  41.      }
  42.      if (!bTargetFound){ //if no match found
  43.      //dynamically add the frame target value to bottom of picklist
  44.        frameTarget.options[counter] = new Option(targetVal);
  45.        frameTarget.selectedIndex = counter;
  46.      }
  47.   }
  48.   
  49.   //fill in href value
  50.   if (hrefVal)
  51.     Href.value = hrefVal;
  52.   else
  53.     Href.value = "";
  54.  
  55.   showHideTranslated();
  56. //  showHideTranslated( baseObj, 'tButtonSpan' );
  57.     
  58. }
  59.  
  60. // ******************** LOCAL FUNCTIONS ****************************
  61.  
  62. function setBaseTag(){
  63.   var baseObj = getSelectedObj(),Attributes;
  64.   var Href=findObject("Href").value;
  65.   var frameTarget=findObject("frameTarget");
  66.   var frameIndex = frameTarget.selectedIndex
  67.   
  68.   if (frameIndex!=0)
  69.     baseObj.setAttribute("target",findObject("frameTarget").options[frameIndex].text)
  70.   else
  71.     baseObj.removeAttribute("target");    
  72.     
  73.   if (Href)
  74.     baseObj.setAttribute("href",Href);   
  75. }
  76.  
  77. function browseForFile(){
  78.   var fileName=browseForFileURL();
  79.   if (fileName) 
  80.     findObject("Href").value=fileName;
  81. }
  82.  
  83.